using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QuickLaunch
{
    public delegate void TabPressedEventHandler(object sender, EventArgs e);

    public partial class TextBoxEx : TextBox
    {
        public TextBoxEx()
        {
            InitializeComponent();
        }

        #region Properties

        protected bool tabDisabled = false;

        public bool TabDisabled
        {
            get { return this.tabDisabled; }
            set { this.tabDisabled = value; }
        }

        #endregion

        #region Events

        public event TabPressedEventHandler TabPressed;

        #endregion

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (this.tabDisabled && keyData == Keys.Tab)
            {
                // raise the tab pressed event
                if (TabPressed != null)
                    TabPressed(this, null);
                return true;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }
}
